<?php

namespace app\api\controller;

use app\api\logic\LoginLogic;
use app\api\validate\WechatLoginValidate;
use app\common\controller\ApiController;
use app\common\service\WeChatService;
use EasyWeChat\Kernel\Exceptions\HttpException;
use think\response\Json;

class WechatUser extends ApiController
{
    protected $skipAuth = ['miniProgramLogin'];

    /**
     * 微信小程序登录
     *
     * @return Json
     * @throws HttpException
     */
    public function miniProgramLogin()
    {
        $params = (new WechatLoginValidate())->post()->goCheck('mnpLogin');
        $res = LoginLogic::mnpLogin($params);
        if (false === $res) {
            return $this->fail(LoginLogic::getError());
        }
        return $this->success('', $res);
    }

}